var api = require('../../../../api.js');
var app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {

    },
    //立即领取
  receive:function(){
    var packsid = this.data.packs_id;
    wx.showLoading({
      title: "领取中",
      mask: !0
    }),app.request({
      url: api.user.receive_Packs,
      data: {
        packs_id: packsid
      },
      success: function (t) {
        wx.hideLoading()
        if(t.code == 1){
          wx.showToast({
            title: t.msg,
            duration: 2e3,
            success:function(){

              wx.switchTab({
                url: '/page/casa/pages/myself/myself'
              })
            }
          })
        }else{
          wx.showToast({
            title: t.msg,
            duration: 2000,
            success:function(){
                wx.redirectTo({
                    url: '/page/casa/pages/myself/myself',
                })
            }
          })
        }

      }
    });
  },


    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
      let tath = this;
      console.log(options)
      let packs_id = options.packs_id;//大礼包id

      app.request({
        url: api.user.packs_coupon,
        data: {
          packs_id: packs_id
        },
        //method: "POST",
        success: function (t) {
            console.log(t);
            tath.setData({
              packs:t,
              packs_id: packs_id
            })
        }
      });


    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    }
})